
export {}
// background.js
// 监听来自content-script的消息
chrome.runtime.onMessage.addListener(function (request, sender, sendResponse) {
  console.log('收到来自content-script的消息：')
  console.log(request, sender, sendResponse)
  // console.log(chrome)
  showNotice('teat', 'ewrwe')
  sendResponse('我是后台，我已收到你的消息：' + JSON.stringify(request))
})


function showNotice (title:string, content:string) {
  // 显示一个桌面通知
  // console.log(Notification.permission)
  if (Notification.permission === 'granted') {
    chrome.notifications.create(Math.random() + '',  // id
      {
        type: 'list',
        iconUrl: './assets/images/icon.png',
        appIconMaskUrl: './assets/images/icon.png',
        title: '通知主标题',
        message: '通知副标题',
        contextMessage: '谷歌扩展API了！',
        buttons: [ { title: '按钮1的标题', iconUrl: './assets/images/icon.png' }, { title: '按钮2的标题', iconUrl: './assets/images/icon.png' } ],
        items: [ { title: '消息1', message: '今天天气真好！' }, { title: '消息2', message: '明天天气估计也不错！' } ],
        eventTime: Date.now() + 2000,
      }, (id) => {
        console.log(id)
      }
    )
  }
}
